﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
using ChinaDynastyTours.Assets;

namespace ChinaDynastyTours.Views
{
    public partial class ContractToolForm : DevExpress.XtraEditors.XtraForm
    {
        private string _Path { get; set; }

        public ContractToolForm(string relativePath)
        {
            InitializeComponent();
            _Path = relativePath;
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void ContractToolForm_Load(object sender, EventArgs e)
        {
            string[] files = System.IO.Directory.GetFiles(Path.Combine(Application.StartupPath, AppResources.RelativeContractFilesPath + "\\" + _Path));
            
            if(files!=null && files.Count()>0)
                foreach (string  file in files)
                {
                    lbContractFileList.Items.Add(Path.GetFileName(file));
                }
        }

        private void lbContractFileList_DoubleClick(object sender, EventArgs e)
        {
            if (lbContractFileList.SelectedValue != null)
            {
                string file = Path.Combine(Application.StartupPath, AppResources.RelativeContractFilesPath + "\\" + _Path + "\\" + lbContractFileList.SelectedValue.ToString());
                Process.Start(file);
            }
        }
    }
}
